<?php
namespace app\common\model;

use think\Model;

class Role extends Model
{
    protected $pk    = 'id';
    protected $table = "fs_auth_group";

    public function getRole($where)
    {
        return $this::where($where)->find();
    }

    public function getRoles($where,$page=20, $order = "id desc")
    {
        $list = $this::where($where)->order($order)->paginate($page);
        $data = $list->toArray();
        return $data;
    }

    public function saveRole($data, $where = false)
    {
        if ($where) {
            return $this::where( $where)->update($data);
        } else {
            if ($this::save($data)) {
                return $this->id;
            }
        }
    }

    public function delRole($id)
    {
        if ($id) {
            $where['id'] = ["in", $id];
            return $this::where($where)->delete();
        }
    }
}
